﻿// ***
// *** Copyright (C) 2013, Daniel M. Porrey.  All rights reserved.
// *** Written By Daniel M. Porrey
// ***
// *** This software is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, 
// *** INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. DANIEL M PORREY 
// *** AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE 
// *** OR ITS DERIVATIVES. IN NO EVENT WILL DANIEL M PORREY OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, 
// *** SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF 
// *** OR INABILITY TO USE THIS SOFTWARE, EVEN IF DANIEL M PORREY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 
// ***
// *** Licensed under Microsoft Public License (Ms-PL)
// *** This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, 
// *** do not use the software. Full license details can be found at https://angle.codeplex.com/license.
// ***
namespace Innovative.Geometry
{
	/// <summary>
	/// Provides common .NET static methods that vary between versions.
	/// </summary>
	internal static class Universal
	{
		/// <summary>
		/// The Math functions in PORTABLE libraries only accept and return double. All other libraries accept
		/// decimal. The library works in all decimal values. This class provides decimal based Math functions
		/// for all platforms.
		/// </summary>
		public static class Math
		{
			/// <summary>
			/// Returns the largest integer less than or equal to the specified double-precision
			/// floating-point number.
			/// </summary>
			/// <param name="value">A decimal floating-point number.</param>
			/// <returns>The largest integer less than or equal to d. If d is equal to System.Double.NaN,
			/// System.Double.NegativeInfinity, or System.Double.PositiveInfinity, that value
			/// is returned.</returns>
			public static decimal Floor(decimal value)
			{
#if PORTABLE40 || PORTABLE45
				return (decimal)System.Math.Floor((double)value);
#else
				return System.Math.Floor(value);
#endif
			}

			/// <summary>
			/// Returns the smallest integral value that is greater than or equal to the
			/// specified double-precision floating-point number.
			/// </summary>
			/// <param name="value">A decimal floating-point number.</param>
			/// <returns>The smallest integral value that is greater than or equal to a. If a is equal
			/// to System.Double.NaN, System.Double.NegativeInfinity, or System.Double.PositiveInfinity,
			/// that value is returned. Note that this method returns a System.Double instead
			/// of an integral type.</returns>
			public static decimal Ceiling(decimal value)
			{
#if PORTABLE40 || PORTABLE45
				return (decimal)System.Math.Ceiling((double)value);
#else
				return System.Math.Ceiling(value);
#endif
			}
		}
	}
}
